home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5128 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: hermes.oc.com!usenet
  2. From: Larry Weiss <lfw@oc.com>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Learning C.
  5. Date: Fri, 09 Feb 1996 12:33:30 -0600
  6. Organization: OpenConnect Systems, Dallas, TX, USA
  7. Message-ID: <311B937A.46EB@oc.com>
  8. References: <Pine.SUN.3.90.960209112512.133A-100000@galileo.cris.com>
  9. NNTP-Posting-Host: ocs2228.oc.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (Win16; I)
  14. CC: lfw@oc.com
  15.  
  16. Guy Schlosser wrote:
  17.   
  18.  > How do you incorporate DOS commands such as cd\, dir, or format into
  19.  > a C program or is there a more portable way to do these types of tasks? 
  20.  
  21.  > How do you generate random numbers in C? 
  22.  
  23. A standard C language function named rand() is available for pseudo-random
  24. number generation.  A companion function srand() exists for seeding the
  25. process.
  26.  
  27. A standard C language function named system() is available for requesting
  28. operating services like  format or dir.  You'll need the documentation for
  29. a particular implementation of C to learn the details of how to specify
  30. the command string.   Usually it's straightforward, for example:
  31.  
  32.      system("dir");
  33.